from django.http import HttpResponse

__author__ = 'dmitry'

import urllib.request

def get_user_courses(access_token):
    request = urllib.request.Request("https://api.coursera.org/api/users/v1/me/enrollments")
    request.add_header('Authorization', 'Bearer ' + access_token)
    response = urllib.request.urlopen(request)
    return response.read()

def get_all_courses(request):
    res = urllib.request.urlopen("https://api.coursera.org/api/catalog.v1/courses")
    return HttpResponse(res.read())